<template>
    <div class="layout">
        <div class="user-avatar">
            <img src="../assets/user/xbox.png" alt="">
        </div>
        <input type="text" placeholder="请输入账号"
            v-model="v1"
            @keydown.enter="signin">
        <input type="password" placeholder="请输入密码"
            v-model="v2"
            @keydown.enter="signin">
        <div class="signin"
            @click="signin">登录</div>
    </div>
</template>

<script>
import appNav from '@/components/app-nav.vue'

export default {
    name: "Home",
    components: {
        appNav
    },
    data() {
        return {
            v1: "",
            v2: "",
            user: "大聪明刘彬",
            psw: "123456"
        }
    },
    methods: {
        signin() {
            if (this.v1.length==0||this.v2.length==0) {
                alert("请完整输入账号和密码")
                return;
            }
            if (this.v1==this.user&&this.v2==this.psw) {
                localStorage.setItem('userInfo', this.user)
                this.$router.push({path: '/home'})
            }else{
                console.log("账号或密码错误");
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.layout {
    height: 735px;
    overflow: hidden;
    background-color: #171717;
    .user-avatar {
        width: 100px;
        height: 100px;
        border-radius: 50%;
        background-color: white;
        margin: 0 auto;
        margin-top: 150px;
        margin-bottom: 50px;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;
        img {
            width: 112%;
        }
    }
    input {
        width: 75%;
        height: 50px;
        display: block;
        margin: 0 auto;
        margin-bottom: 20px;
        padding-left: 15px;
        box-sizing: border-box;
        font-size: 20px;
        border-radius: 5px;
        &::placeholder {
            position: absolute;
            margin-left: -50px;
            margin-top: -15px;
            left: 50%;
            top: 50%;
        }
    }
    .signin {
        width: 75%;
        height: 50px;
        line-height: 50px;
        text-align: center;
        font-size: 20px;
        margin: 0 auto;
        border-radius: 5px;
        background-color: white;
    }
}
</style>
